# -*- coding:UTF-8 -*-
import math
def a(n):
    if n > 1:
   # 查看因子
        for i in range(2,int(math.sqrt(n))+1):
            if (n % i) == 0:
                
                break
        else:

            print(n)
            save.append(n)
    else:
        
    
        return    
print("质数生成程序")
e=int(input("起始数字:"))
f=int(input("最终数字:"))
y=("是","要","Y","yes")
n=("否","不要","N","no")
save=[]
b=1
for b in range(e,f):
    a(b)     

answer = input('要保存吗：')
if answer in y: 
    yesorno="保存"
elif answer in n:
    yesorno="不保存"
else:
    print("未识别，默认不保存") 
    yesorno="不保存"
print(yesorno)
if yesorno=="保存":
    print("正在保存")
    TXT=open("质数.txt","w")
    for d in range(1,len(save)):
        TXT.write(str(save[d])+"\n")
    TXT.close()
    
